package com.cfuture08.home.action.columns;

import com.cfuture08.eweb4j.component.dwz.DWZUtil;
import com.cfuture08.eweb4j.mvc.action.Action;
import com.cfuture08.eweb4j.mvc.action.ActionSupport;
import com.cfuture08.eweb4j.orm.dao.DAO;
import com.cfuture08.home.vo.Columns;

public class AddColumns extends ActionSupport {
	private Columns columns;

	public String execute() {
		if (DAO.selectOne(columns, new String[] { "name" }) == null) {

			out.print(DAO.insert(this.columns) == true ? DWZUtil
					.getSuccessJson("添加栏目" + columns.getName() + "成功",
							"xssylm", "showAllColumns.do", null) : DWZUtil
					.getFailedJson("添加栏目" + this.columns.getName() + "失败"));
		} else {
			out.print(DWZUtil.getFailedJson("添加栏目" + columns.getName()
					+ "失败,该栏目名字已经存在"));
		}
		return Action.AJAX;
	}

	public Columns getColumns() {
		return columns;
	}

	public void setColumns(Columns columns) {
		this.columns = columns;
	}
}
